package demo.jdk.features.jdk8;

/**
 * @author Ranchoz  2018/9/9 17:32
 **/

import demo.jdk.features.Base.Artist;
import demo.jdk.features.Base.ArtistFactory;
import demo.jdk.features.Base.SampleData;
import org.junit.Test;

/**
 * 静态方法引用：ClassName::methodName
 * 实例上的实例方法引用：instanceReference::methodName
 * 超类上的实例方法引用：super::methodName
 * 类型上的实例方法引用：ClassName::methodName
 * 构造方法引用：Class::new
 * 数组构造方法引用：TypeName[]::new
 * Created by patterncat on 2016-02-05.
 */
public class MethodReference {

	@Test
	public void methodRef() {
		SampleData.getThreeArtists().stream()
				.map(Artist::getName)
				.forEach(System.out::println);
	}

	@Test
	public void constructorRef() {
		ArtistFactory<Artist> af = Artist::new;
		Artist a = af.create("patterncat", "china");
		System.out.println(a);
	}
}
